package com.itfreer.file;

import java.io.Serializable;

/**
 * 定义断点续传文件块信息
 */
public class FileSegmentInfo implements Cloneable, Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 文件总长度
     */
    private long fileLength;

    /**
     * 文件块索引
     * 从0开始
     */
    private Long segmentIndex;

    /**
     * 文件块大小
     * 单位为b
     */
    private Integer segmentSize;

    /**
     * 文件块内容
     */
    private byte[] segmentContent;

    /**
     * 文件总块数
     */
    private Long segmentCount;
    /**
     * 是否最后一个
     */
    private Boolean lastSegment;

    /**
     * 文件块索引
     * 从0开始
     */
    public Long getSegmentIndex() {
        return segmentIndex;
    }

    /**
     * 文件块索引
     */
    public void setSegmentIndex(Long segmentIndex) {
        this.segmentIndex = segmentIndex;
    }

    /**
     * 文件块大小
     */
    public Integer getSegmentSize() {
        return segmentSize;
    }

    /**
     * 文件块大小
     * 单位为kb
     */
    public void setSegmentSize(Integer segmentSize) {
        this.segmentSize = segmentSize;
    }

    /**
     * 文件块内容
     */
    public byte[] getSegmentContent() {
        return segmentContent;
    }

    /**
     * 文件块内容
     */
    public void setSegmentContent(byte[] segmentContent) {
        this.segmentContent = segmentContent;
    }

    /**
     * 文件总长度
     */
    public long getFileLength() {
        return fileLength;
    }

    /**
     * 文件总长度
     */
    public void setFileLength(long fileLength) {
        this.fileLength = fileLength;
    }

    /**
     * 文件块总数
     */
    public Long getSegmentCount() {
        return segmentCount;
    }

    public void setSegmentCount(Long value){
        this.segmentCount = value;
    }

    /**
     * 最否是最后文件块
     */
    public Boolean isLastSegment() {
        return lastSegment;
    }

    public void setLastSegment(Boolean value){
        this.lastSegment = value;
    }

    @Override
    public Object clone() {
        FileSegmentInfo cloneObject = new FileSegmentInfo();
        cloneObject.fileLength = this.fileLength;
        cloneObject.segmentContent = this.segmentContent;
        cloneObject.segmentIndex = this.segmentIndex;
        cloneObject.segmentSize = this.segmentSize;
        cloneObject.segmentCount = this.segmentCount;
        cloneObject.lastSegment = this.lastSegment;
        return cloneObject;
    }
}
